<template>
  <div class="login">
    <!-- 使用echarts -->
    <div ref="echarts1" class="line-chart">

    </div>
  </div>
</template>

<script>
const echarts = require('echarts/lib/echarts');
require('echarts/lib/chart/line')   // 引入折线图
// 引入提示框和title组件，图例
require('echarts/lib/component/tooltip')
require('echarts/lib/component/title')
require('echarts/lib/component/legend')
export default {
  data() {
    return {
    };
  },
  created() {},
  mounted() {
    this.myEcharts1()
    
  },
  methods: {
    myEcharts1() {
      const myChart = echarts.init(this.$refs.echarts1)
    const option = {
        title: {
          text: "数据展示",
        },
        tooltip: {
          trigger: "axis",
        },
        legend: {
          data: ["报修总数", "投诉总数"],
          textStyle: {
            color: "red",
            fontSize: 18,
          },
        },
        grid: {
          left: "5%",
          right: "5%",
          bottom: "3%",
          containLabel: true,
        },
        toolbox: {
          feature: {
            saveAsImage: {},
          },
        },
        xAxis: {
          type: "category",
          boundaryGap: false,
          data: ["一月", "二月", "三月", "四月", "五月", "六月", "七日"],
        },
        yAxis: {
          type: "value",
        },
        series: [
          {
            name: "投诉总数",
            type: "line",
            stack: "总量",
            data: [120, 132, 101, 134, 90, 230, 210],
          },
          {
            name: "报修总数",
            type: "line",
            stack: "总量",
            data: [220, 182, 191, 234, 290, 330, 310],
          },
        ],
      };

      myChart.setOption(option);
      window.onresize = function () {
        myChart.resize()
      }
    },
  },
};
</script>

<style lang="less" scoped>
.line-chart {
  width: 80%;
  height: 500px;
  margin-left: -18px;
  margin-top: 30px;
}
</style>